package com.sixth.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class OrderUtil {

    public static String getOrderNo() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        int randomNum = (int) (Math.random() * 100000); // 生成0到99999之间的随机数
        String formattedRandomNum = String.format("%05d", randomNum); // 格式化为5位，不足补零
        return "ODC" + dtf.format(LocalDateTime.now()) + formattedRandomNum;
    }

    public static String getOrderNoBackFeeNo() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        int randomNum = (int) (Math.random() * 100000); // 生成0到99999之间的随机数
        String formattedRandomNum = String.format("%05d", randomNum); // 格式化为5位，不足补零
        return "ODB" + dtf.format(LocalDateTime.now()) + formattedRandomNum;
    }

    public static String backPlatformId() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        int randomNum = (int) (Math.random() * 100000); // 生成0到99999之间的随机数
        String formattedRandomNum = String.format("%08d", randomNum); // 格式化为8位，不足补零
        return dtf.format(LocalDateTime.now()) + formattedRandomNum;
    }

    public static String OrderTimeOutNo() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        long randomNum = (long) (Math.random() * Math.pow(10, 18)); // 生成0到999999999999999999之间的随机数
        String formattedRandomNum = String.format("%018d", randomNum); // 格式化为18位，不足补零
        return "OTO" + dtf.format(LocalDateTime.now()) + formattedRandomNum;
    }

    public static void main(String[] args) {
        System.out.println(backPlatformId()); // 测试生成的订单号
        System.out.println(OrderTimeOutNo()); // 测试超时订单号
    }
}
